<template>
    <el-tabs v-model="activeName" @tab-click="handleClick" class="order-tab">
        <el-tab-pane label="等待确认" name="first">
            <el-input placeholder="请输入查询内容" v-model="search.searchValue" class="input-with-select">
                <el-select v-model="search.searchType" slot="prepend" placeholder="请选择" class="kkk">
                    <el-option label="名字" value="name"></el-option>
                    <el-option label="创建时间" value="createTime"></el-option>
                    <el-option label="商品数量" value="num"></el-option>
                </el-select>
                <el-button slot="append" icon="el-icon-search" @click="serchGoods"></el-button>
            </el-input>

            <el-table 
            :data="pageData.rows" style="width: 100%" 
            :row-class-name="tableRowClassName"
            height="230px"
            >
                <el-table-column prop="createTime" label="创建时间" width="180">
                </el-table-column>
                <el-table-column label="车辆信息">
                    <template slot-scope="scope">
                        <img :src="scope.row.carId.imgs[0].headImagePath" width="100px" />
                    </template>
                </el-table-column>
                <el-table-column prop="rental.name" label="出租人姓名">
                </el-table-column>
                <el-table-column prop="rental.phoneNumber" label="出租人电话">
                </el-table-column>
                <el-table-column prop="leasee.name" label="承租人姓名">
                </el-table-column>
                <el-table-column prop="leasee.phoneNumber" label="承租人电话">
                </el-table-column>
                <el-table-column prop="orderState" label="订单状态">
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="pageData.currentPage" :page-sizes="[1, 2, 3, 4]" :page-size="2"
                layout="total, sizes, prev, pager, next, jumper" :total="pageData.total">
            </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="待支付" name="second">
            <el-table
            height="280px"
             :data="pageData2.rows" style="width: 100%" :row-class-name="tableRowClassName">
                <el-table-column prop="createTime" label="创建时间" width="180">
                </el-table-column>
                <el-table-column label="车辆信息">
                    <template slot-scope="scope">
                        <img :src="scope.row.carId.imgs[0].headImagePath" width="100px" />
                    </template>
                </el-table-column>
                <el-table-column prop="rental.name" label="出租人姓名">
                </el-table-column>
                <el-table-column prop="rental.phoneNumber" label="出租人电话">
                </el-table-column>
                <el-table-column prop="leasee.name" label="承租人姓名">
                </el-table-column>
                <el-table-column prop="leasee.phoneNumber" label="承租人电话">
                </el-table-column>
                <el-table-column prop="orderState" label="订单状态">
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
                :current-page="pageData2.currentPage" :page-sizes="[1, 2, 3, 4]" :page-size="pageData2.pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="pageData2.total">
            </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="交易失败" name="third">
            <el-table 
            height="280px"
            :data="pageData3.rows" style="width: 100%" :row-class-name="tableRowClassName">
                <el-table-column prop="createTime" label="创建时间" width="180">
                </el-table-column>
                <el-table-column label="车辆信息">
                    <template slot-scope="scope">
                        <img :src="scope.row.carId.imgs[0].headImagePath" width="100px" />
                    </template>
                </el-table-column>
                <el-table-column prop="rental.name" label="出租人姓名">
                </el-table-column>
                <el-table-column prop="rental.phoneNumber" label="出租人电话">
                </el-table-column>
                <el-table-column prop="leasee.name" label="承租人姓名">
                </el-table-column>
                <el-table-column prop="leasee.phoneNumber" label="承租人电话">
                </el-table-column>
                <el-table-column prop="orderState" label="订单状态">
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange3" @current-change="handleCurrentChange3"
                :current-page="pageData3.currentPage" :page-sizes="[1, 2, 3, 4]" :page-size="pageData3.pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="pageData3.total">
            </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="已支付" name="fourth">
            <el-table
            height="280px"
             :data="pageData4.rows" style="width: 100%" :row-class-name="tableRowClassName">
                <el-table-column prop="createTime" label="创建时间" width="180">
                </el-table-column>
                <el-table-column label="车辆信息">
                    <template slot-scope="scope">
                        <img :src="scope.row.carId.imgs[0].headImagePath" width="100px" />
                    </template>
                </el-table-column>
                <el-table-column prop="rental.name" label="出租人姓名">
                </el-table-column>
                <el-table-column prop="rental.phoneNumber" label="出租人电话">
                </el-table-column>
                <el-table-column prop="leasee.name" label="承租人姓名">
                </el-table-column>
                <el-table-column prop="leasee.phoneNumber" label="承租人电话">
                </el-table-column>
                <el-table-column prop="orderState" label="订单状态">
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange4" @current-change="handleCurrentChange4"
                :current-page="pageData4.currentPage" :page-sizes="[1, 2, 3, 4]" :page-size="pageData4.pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="pageData4.total">
            </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="交易完成" name="five">
            <el-table 
            height="280px"
            :data="pageData5.rows" style="width: 100%" :row-class-name="tableRowClassName">
                <el-table-column prop="createTime" label="创建时间" width="180">
                </el-table-column>
                <el-table-column label="车辆信息">
                    <template slot-scope="scope">
                        <img :src="scope.row.carId.imgs[0].headImagePath" width="100px" />
                    </template>
                </el-table-column>
                <el-table-column prop="rental.name" label="出租人姓名">
                </el-table-column>
                <el-table-column prop="rental.phoneNumber" label="出租人电话">
                </el-table-column>
                <el-table-column prop="leasee.name" label="承租人姓名">
                </el-table-column>
                <el-table-column prop="leasee.phoneNumber" label="承租人电话">
                </el-table-column>
                <el-table-column prop="orderState" label="订单状态">
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange5" @current-change="handleCurrentChange5"
                :current-page="pageData5.currentPage" :page-sizes="[1, 2, 3, 4]" :page-size="pageData5.pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="pageData5.total">
            </el-pagination>

        </el-tab-pane>
    </el-tabs>
</template>

<script>
    import { createNamespacedHelpers } from "vuex";
    const {
        mapState: mapState,
        mapActions: mapActions,
        mapMutations: mapMutations
    } = createNamespacedHelpers("mycenter");
    export default {
        data() {
            return {
                search: {
                    searchType: "",
                    searchValue: ""
                },
                activeName: 'first',
                tab: ""
            }
        },
        created() {
            this.getlist();
            // console.log(this.pageData.rows)
        },
        computed: {
            ...mapState(["pageData", "pageData2", "pageData3", "pageData4", "pageData5"])
        },
        methods: {
            // ...mapMutations(["changepageSize", "changePage"]),
            ...mapActions(["getlist", 'getlist2', 'getlist3', 'getlist4', 'getlist5',
                'handleCurrentChange', 'handleSizeChange',
                'handleCurrentChange2', 'handleSizeChange2',
                'handleCurrentChange3', 'handleSizeChange3',
                'handleCurrentChange4', 'handleSizeChange4',
                'handleCurrentChange5', 'handleSizeChange5',
            ]),

            tableRowClassName({ row, rowIndex }) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },
            handleClick(tab, event) {
                // console.log("mmm0",tab, event);
                this.tab = tab.index
                if (tab.index == 1) {
                    this.getlist2()
                }
                if (tab.index == 2) {
                    this.getlist3()
                }
                if (tab.index == 3) {
                    this.getlist4()
                }
                if (tab.index == 4) {
                    this.getlist5()
                }
                if (tab.index == 0) {
                    this.getlist()
                }
            },
            serchGoods() {
                console.log();
                //  this.getStudentsAsync()
                this.getlist(this.search);
            }
        },

    };
</script>

<style>
    .el-table .warning-row {
        background: oldlace;
    }

    .el-table .success-row {
        background: #f0f9eb;
    }
    .kkk{
        width: 120px;
    }
    .order-tab .el-tabs__item{
        line-height: 25px !important;
    }
</style>